package car.activities;

import car.manager.BackStageManager;
import car.manager.R;
import car.manager.UserProfile;
import car.manager.R.id;
import car.manager.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class NewProfileActivity extends Activity{
	
	EditText username_field;
	
	public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        
	        setContentView(R.layout.new_profile_form);
	        
	        
	        username_field   = (EditText)findViewById(R.id.usernameText);

	        
	        Button b1 = (Button) findViewById(R.id.button_create_user);
	       
	        b1.setOnClickListener(new View.OnClickListener() {
	            public void onClick(View v) {
	            	createNewProfile();
	            }
	        });

	        Button b2 = (Button) findViewById(R.id.button_back_to_main);

	        b2 = (Button) findViewById(R.id.button_back_to_main);
	        b2.setOnClickListener(new View.OnClickListener() {
	            public void onClick(View v) {
	            	NewProfileActivity.this.backToMain();
	            }
	        });

}


	protected void createNewProfile() {
		//	finish();

		     Log.v("cunhaDebug", "CAGALHAAAAOOOO AINDA NAO SAIUUUUU");
		
		
		BackStageManager app =  (BackStageManager) getApplication();
		
	     Log.v("cunhaDebug", "CAGALHAAAAOOOO JJJAAAAAAAAAAAA NAO SAIUUUUU");

		app.addProfile(new UserProfile(username_field.getText().toString()));
		Intent start_profile_manager_intent = new Intent(this, ProfileManagerActivity.class);
		startActivity(start_profile_manager_intent);	
		
		
	}
	
	protected void backToMain() {

		
		finish();
	}

	
}
